import {defineStore} from "pinia";
import {ref} from "vue";

export const useUserStore = defineStore('user', () => {
    //用户id,token
    const id = ref("")
    const token = ref("")
    const account = ref({})
    const perPath = ref("/")
    //重置用户信息
    const reset = path => {
        id.value = ""
        token.value = ""
        account.value = {}
        if(path) perPath.value = path
        else perPath.value = location.pathname
        location.replace("/login")
    }
    return {id,token,account,perPath,reset}
}, {
    persist: true
})